import axios from 'axios'

const API_BASE_URL = 'https://ai-agent-backend-137612-10-1339784673.sh.run.tcloudbase.com'

const apiClient = axios.create({
  baseURL: API_BASE_URL,
  headers: {
    'Content-Type': 'application/json'
  }
})

export const aiService = {
  /**
   * 与AI恋爱大师聊天（SSE方式）
   * @param {string} question - 用户问题
   * @param {string} chatId - 聊天ID
   * @returns {EventSource} - SSE事件源
   */
  doChatWithLoveAppSse(question, chatId) {
    const url = `${API_BASE_URL}/ai/chat/sse_emitter?question=${encodeURIComponent(question)}&chatId=${encodeURIComponent(chatId)}`
    return new EventSource(url)
  },

  /**
   * 与AI超级智能体聊天（SSE方式）
   * @param {string} question - 用户问题
   * @param {string} chatId - 聊天ID
   * @returns {EventSource} - SSE事件源
   */
  doChatWithManus(question, chatId) {
    // 使用正确的后端接口 /agent/stream
    const url = `${API_BASE_URL}/ai/agent/stream?question=${encodeURIComponent(question)}`
    return new EventSource(url)
  }
}